package com.wut.minio.service.impl;

import com.wut.minio.service.MinioService;
import com.wut.minio.utils.MinioUtil;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class MinioServiceImpl implements MinioService {

    private final MinioUtil minioUtil;

    public MinioServiceImpl(MinioUtil minioUtil) {
        this.minioUtil = minioUtil;
    }

    @Override
    public String upload(String bucketName, MultipartFile file) {
        return minioUtil.upload(bucketName, file.getOriginalFilename(), file);
    }

    @Override
    public String getFilePath(String bucketName, String fileName) {
        return minioUtil.getFilePath(bucketName, fileName);
    }

    @Override
    public Boolean download(String bucketName, String fileName, HttpServletResponse response) {
        return minioUtil.download(bucketName, fileName, response);
    }

    @Override
    public Boolean remove(String bucketName, String fileName) {
        return minioUtil.remove(bucketName, fileName);
    }
}
